package shake.el;

import java.beans.FeatureDescriptor;
import java.util.Iterator;

import javax.el.ELContext;
import javax.el.ELException;
import javax.el.ELResolver;
import javax.el.PropertyNotFoundException;
import javax.el.PropertyNotWritableException;

import shake.servlet.ShakeServletContext;

public class ShakeELResolver extends ELResolver {

	static public ComponentElResolver getElResolver() {
		return ShakeServletContext.getInjector()
				.getInstance(ComponentElResolver.class);
	}

	@Override
	public Class<?> getCommonPropertyType(ELContext context, Object base) {
		return getElResolver().getCommonPropertyType(context, base);
	}

	@Override
	public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context,
			Object base) {
		return getElResolver().getFeatureDescriptors(context, base);
	}

	@Override
	public Class<?> getType(ELContext context, Object base, Object property)
			throws NullPointerException, PropertyNotFoundException, ELException {
		return getElResolver().getType(context, base, property);
	}

	@Override
	public Object getValue(ELContext context, Object base, Object property)
			throws NullPointerException, PropertyNotFoundException, ELException {
		return getElResolver().getValue(context, base, property);

	}

	@Override
	public boolean isReadOnly(ELContext context, Object base, Object property)
			throws NullPointerException, PropertyNotFoundException, ELException {
		return getElResolver().isReadOnly(context, base, property);

	}

	@Override
	public void setValue(ELContext context, Object base, Object property,
			Object value) throws NullPointerException,
			PropertyNotFoundException, PropertyNotWritableException,
			ELException {
		getElResolver().setValue(context, base, property, value);
	}

}
